// Sunghan Cho
// 301140084
// sunghanc@sfu.ca

#include "selectedstudentlistmodel.h"
#include "QDebug"

SelectedStudentListModel::SelectedStudentListModel(QObject *parent) : ItemListModel(parent)
{
}

SelectedStudentListModel::SelectedStudentListModel(ItemManager *pItemManager, QObject *parent) : ItemListModel(pItemManager, parent)
{
}

bool SelectedStudentListModel::shouldIncludeInList(Item *pNewItem)
{
    Student* std = dynamic_cast<Student*>(pNewItem);

    if (std->hasTakenCourse(m_pSelectedCourse)){
        return true;
    }
    if (m_pSelectedCourse == NULL){
        return true;
    }
    return true;
}

void SelectedStudentListModel::setSelectedCourse(Item *pItem)
{
    //qDebug()<<"SelectedStudentListMode::setSelectedCourse SLOT recieved";
    m_pSelectedCourse = dynamic_cast<Course*>(pItem);
    ItemListModel::updateItems();
}
